package com.hh.test.design.flyweight;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {
	static Map<String, Flyweight> map = new HashMap<>();

	public static void main(String[] args) {
		FlyweightFactory.getFly("RED").draw();
		FlyweightFactory.getFly("BLUE").draw();
	}

	public static Flyweight getFly(String colour) {
		if (map.get(colour) == null) {
			map.put(colour, new Circle(colour));
		}
		return map.get(colour);
	}
}
